Skip to content

Correct the use of connections strings in integration documents#314

Open
alistairmatthews wants to merge 7 commits intomicrosoft:mainfrom
alistairmatthews:remove-incorrect-connection-string-code
Open

Correct the use of connections strings in integration documents#314
alistairmatthews wants to merge 7 commits intomicrosoft:mainfrom
alistairmatthews:remove-incorrect-connection-string-code

Conversation

@alistairmatthews
Copy link
Contributor

@alistairmatthews alistairmatthews commented Jan 29, 2026

Although in the Dashboard there is often an environment variable such as ConnectionStrings__postgresdb listed, this shouldn't be used in .NET code for two reasons:

  • The double-underscore returns null and should be replaced with a colon.
  • We should always encourage the Aspire method instead: var connectionUri = builder.Configuration.GetConnectionString("postgresdb");

The double-underscore version is correct for Python and JavaScript examples.

Fixes: #312

@alistairmatthews alistairmatthews marked this pull request as ready for review February 2, 2026 16:19
Copilot AI review requested due to automatic review settings February 2, 2026 16:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR corrects the documentation for database integration by removing incorrect references to ConnectionStrings__<name> environment variables and replacing them with the proper Aspire method GetConnectionString("<name>"). The double-underscore format doesn't work correctly and should not be recommended to developers.

Changes:

  • Updated C# code examples to use GetConnectionString() instead of GetValue<string>("ConnectionStrings__<name>")
  • Removed ConnectionStrings__<name> from environment variable lists in various integration documentation files
  • Removed entire documentation sections that demonstrated the incorrect pattern

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
qdrant-host.mdx Removes incorrect ConnectionStrings__qdrant from environment variable list
qdrant-get-started.mdx Updates C# example to use GetConnectionString and removes Python/JavaScript examples with incorrect pattern
mongodb-host.mdx Removes ConnectionStrings__mongodb from environment variable list
milvus-host.mdx Removes ConnectionStrings__milvusdb from environment variable list
milvus-get-started.mdx Updates C# example to use GetConnectionString with var keyword
elasticsearch-get-started.mdx Removes entire section about injected Elasticsearch properties
sql-server-client.mdx Removes ConnectionString property from documentation table and environment variable list
postgresql-client.mdx Removes ConnectionString from table and updates explanatory text
oracle-host.mdx Removes ConnectionStrings__oracledb from environment variable list
mysql-get-started.mdx Updates C# example to use GetConnectionString with var keyword

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


The following environment variables are available in the Python application:

- `ConnectionStrings__oracledb` - The connection string for the Oracle database
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this true? I thought connection strings were still present.

@alistairmatthews
Copy link
Contributor Author

Closing to re-trigger checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove code that uses the ConnectionStrings__<name> environment variable

2 participants